<?php
/** 
* Report_bug_model Class 
* @package TIAP 
* @subpackage Model 
* @category your_info 
* @author Harits Balfas 
* @link http://twitter.com/jeblagsancang 
*/ 
class Report_bug_model extends MY_Model{
    var $your_info_table;
    
    function Report_bug_model(){
        parent::MY_Model();
        $this->report_bug_table = 'report_bug';
        $this->user_tiab_table = 'user_tiab';
    }
    /*
    * method add_crime_report_comment
    * add crime report comment
    * 
    * @param mixed $crime_report_id
    * @param mixed $user_tiab_id
    * @param mixed $comment
    * 
    * @return string query
    */
    // insert comments to database if the user is TIA user
    function add_report_bug($name, $email, $problem, $browser_info, $image){
                
        $array_insert_report_bug = array(
            'name'          => $name,
            'email'         => $email,
            'problem'       => $problem,
            'image'         => $image,
            'browser_info'  => $browser_info,
            'ip_address'    => $_SERVER['REMOTE_ADDR'],
            'created_date'  => date('Y-m-d H:i:s'),
            'address'       => $_SERVER['HTTP_REFERER']
        );
        $result =  $this->db->insert($this->report_bug_table, $array_insert_report_bug);
        $config = array(
          'mailtype'=>'html'
        );    
        $data = array(
          'name'=>$name,
          'email'=>$email,
          'problem'=>$problem,
          'image_link'=>base_url().'uploads/bug/thumb/'.$image,
          'image'=>$image,
          'browser'=>$browser_info,
          'address'=>$_SERVER['HTTP_REFERER'] 
        );
        $email_content = $this->load->view(TEMPLATE_NAME.'/front/mail/bug_email',$data, true);
        $this->load->library('email');
        $this->email->initialize($config);    
        $this->email->from('noreply@turnitaround.co.za', 'Turn It Around');
        $list = array('arun.uba@gmail.com', 'arjunnccs@gmail.com', 'gerald@in-detail.com', 'info@turnitaround.co.za','setyagus@icreativelabs.com');
		$this->email->to($list);
        //$this->email->to('info@turnitaround.co.za','general@icreativelabs.com');        
        //$this->email->to('haritsbalfas10@gmail.com');
        $this->email->subject('Bug Report');
        $this->email->message($email_content);
        if($this->email->send()){
          return TRUE;
        }else{
          return FALSE;
        }
	if(!empty($result)){
	    return $this->db->last_query();//$this->db->insert_id();
	}else{
	}
        return FALSE;              
    }
    
}

/* End of file report_bug_model.php */
/* Location: ./system/application/models/report_bug_model.php */
